`.lastRequest` <- 10

`.twsOutgoingMSG` <-
structure(list(REQ_MKT_DATA = "1", CANCEL_MKT_DATA = "2", PLACE_ORDER = "3", 
    CANCEL_ORDER = "4", REQ_OPEN_ORDERS = "5", REQ_ACCOUNT_DATA = "6", 
    REQ_EXECUTIONS = "7", REQ_IDS = "8", REQ_CONTRACT_DATA = "9", 
    REQ_MKT_DEPTH = "10", CANCEL_MKT_DEPTH = "11", REQ_NEWS_BULLETINS = "12", 
    CANCEL_NEWS_BULLETINS = "13", SET_SERVER_LOGLEVEL = "14", 
    REQ_AUTO_OPEN_ORDERS = "15", REQ_ALL_OPEN_ORDERS = "16", 
    REQ_MANAGED_ACCTS = "17", REQ_FA = "18", REPLACE_FA = "19", 
    REQ_HISTORICAL_DATA = "20", EXERCISE_OPTIONS = "21", REQ_SCANNER_SUBSCRIPTION = "22", 
    CANCEL_SCANNER_SUBSCRIPTION = "23", REQ_SCANNER_PARAMETERS = "24", 
    CANCEL_HISTORICAL_DATA = "25", REQ_CURRENT_TIME = "49", REQ_REAL_TIME_BARS = "50", 
    CANCEL_REAL_TIME_BARS = "51", REQ_FUNDAMENTAL_DATA = "52",
    CANCEL_FUNDAMENTAL_DATA = "53", REQ_CALC_IMPLIED_VOLAT = "54",
    REQ_CALC_OPTION_PRICE = "55", CANCEL_CALC_IMPLIED_VOLAT = "56",
    CANCEL_CALC_OPTION_PRICE = "57"), .Names = c("REQ_MKT_DATA", 
"CANCEL_MKT_DATA", "PLACE_ORDER", "CANCEL_ORDER", "REQ_OPEN_ORDERS", 
"REQ_ACCOUNT_DATA", "REQ_EXECUTIONS", "REQ_IDS", "REQ_CONTRACT_DATA", 
"REQ_MKT_DEPTH", "CANCEL_MKT_DEPTH", "REQ_NEWS_BULLETINS", "CANCEL_NEWS_BULLETINS", 
"SET_SERVER_LOGLEVEL", "REQ_AUTO_OPEN_ORDERS", "REQ_ALL_OPEN_ORDERS", 
"REQ_MANAGED_ACCTS", "REQ_FA", "REPLACE_FA", "REQ_HISTORICAL_DATA", 
"EXERCISE_OPTIONS", "REQ_SCANNER_SUBSCRIPTION", "CANCEL_SCANNER_SUBSCRIPTION", 
"REQ_SCANNER_PARAMETERS", "CANCEL_HISTORICAL_DATA", "REQ_CURRENT_TIME", 
"REQ_REAL_TIME_BARS", "CANCEL_REAL_TIME_BARS","REQ_FUNDAMENTAL_DATA","CANCEL_FUNDAMENTAL_DATA",
"REQ_CALC_IMPLIED_VOLAT","REQ_CALC_OPTION_PRICE","CANCEL_CALC_IMPLIED_VOLAT",
"CANCEL_CALC_OPTION_PRICE"))

`.twsIncomingMSG` <-
structure(list(TICK_PRICE = "1", TICK_SIZE = "2", 
    ORDER_STATUS = "3", ERR_MSG = "4", OPEN_ORDER = "5", ACCT_VALUE = "6", 
    PORTFOLIO_VALUE = "7", ACCT_UPDATE_TIME = "8", NEXT_VALID_ID = "9", 
    CONTRACT_DATA = "10", EXECUTION_DATA = "11", MARKET_DEPTH = "12", 
    MARKET_DEPTH_L2 = "13", NEWS_BULLETINS = "14", MANAGED_ACCTS = "15", 
    RECEIVE_FA = "16", HISTORICAL_DATA = "17", BOND_CONTRACT_DATA = "18", 
    SCANNER_PARAMETERS = "19", SCANNER_DATA = "20", TICK_OPTION_COMPUTATION = "21", 
    TICK_GENERIC = "45", TICK_STRING = "46", TICK_EFP = "47", 
    CURRENT_TIME = "49", REAL_TIME_BARS = "50", FUNDAMENTAL_DATA = "51",
    CONTRACT_DATA_END = "52", OPEN_ORDER_END = "53",
    ACCT_DOWNLOAD_END = "54", EXECUTION_DATA_END = "55",
    DELTA_NEUTRAL_VALIDATION = "56", TICK_SNAPSHOT_END = "57"), .Names = c("TICK_PRICE", 
"TICK_SIZE", "ORDER_STATUS", "ERR_MSG", "OPEN_ORDER", "ACCT_VALUE", 
"PORTFOLIO_VALUE", "ACCT_UPDATE_TIME", "NEXT_VALID_ID", "CONTRACT_DATA", 
"EXECUTION_DATA", "MARKET_DEPTH", "MARKET_DEPTH_L2", "NEWS_BULLETINS", 
"MANAGED_ACCTS", "RECEIVE_FA", "HISTORICAL_DATA", "BOND_CONTRACT_DATA", 
"SCANNER_PARAMETERS", "SCANNER_DATA", "TICK_OPTION_COMPUTATION", 
"TICK_GENERIC", "TICK_STRING", "TICK_EFP", "CURRENT_TIME", "REAL_TIME_BARS",
"FUNDAMENTAL_DATA","CONTRACT_DATA_END", "OPEN_ORDER_END", "ACCT_DOWNLOAD_END",
"EXECUTION_DATA_END","DELTA_NEUTRAL_VALIDATION","TICK_SNAPSHOT_END"
))

`.twsERR` <-
structure(c("Max rate of messages per second has been exceeded.", 
"Max number of tickers has been reached.", "Duplicate ticker ID.", 
"Duplicate order ID.", "Can't modify a filled order.", "Order being modified does not match original order.", 
"Can't transmit order ID.", "Cannot transmit incomplete order.", 
"Price is out of the range defined by the Percent Setting at order defaults frame. The order will not be transmitted.", 
"The price does not conform to the minimum price variation for this contract.", 
"The Time in force (tif type) and the order type are incompatible.", 
"The Tif option should be set to DAY for MOC and LOC orders.", 
"Relative orders are valid for stocks only.", "Relative orders for US stocks can only be submitted to SMART, SMART_ECN, INSTINET, or PRIMEX.", 
"The order cannot be transmitted to a dead exchange.", "The block order size must be at least 50.", 
"VWAP orders must be routed through the VWAP exchange.", "Only VWAP orders may be placed on the VWAP exchange.", 
"It is too late to place a VWAP order for today.", "Invalid BD flag for the order. Check \"Destination\" and \"BD\" flag.", 
"No request tag has been found for order:", "No record is available for conid:", 
"No market rule is available for conid:", "Buy price must be the same as the best asking price.", 
"Sell price must be the same as the best bidding price.", "Linkage orders are not supported on this exchange.", 
"Linkage customers cannot submit non-linkage orders for options.", 
"VWAP orders must be submitted at least three minutes before the start time.", 
"The sweep-to-fill flag and display size are only valid for US stocks routed through SMART, and will be ignored.", 
"This order cannot be transmitted without a clearing account.", 
"Submit new order failed.", "Modify order failed.", "Can't find order with ID =", 
"This order cannot be cancelled.", "VWAP orders can only be cancelled up to three minutes before the start time.", 
"Could not parse ticker request.", "Parsing error:", "The size value should be an integer:", 
"The price value should be a double:", "Institutional customer account does not have account info", 
"Requested ID is not an integer number.", "Order size does not match total share allocation.", 
"Error in validating entry fields.", "Invalid trigger method.", 
"The conditional contract info is incomplete.", "A conditional order can only be submitted when the order type is set to limit or market.", 
"This order cannot be transmitted without a user name.", "The \"hidden\" order attribute may not be specified for this order.", 
"EFPs can only be limit orders.", "Orders cannot be transmitted for a halted security.", 
"A sizeOp order must have a username and account.", "A SizeOp order must go to IBSX", 
"An order can be EITHER Iceberg or Discretionary. Please remove either the Discretionary amount or the Display size.", 
"You must specify an offset amount or a percent offset value.", 
"The percent offset value must be between 0% and 100%.", "The size value cannot be zero.", 
"Cancel attempted when order is not in a cancellable state. Order permId =", 
"Historical market data Service error message.", "Historical market Data Service query message.", 
"HMDS Expired Contract Violation.", "VWAP order time must be in the future.", 
"Discretionary amount does not conform to the minimum price variation for this contract.", 
"No security definition has been found for the request.", "Order rejected - Reason:", 
"Order cancelled - Reason:", "The security (   ) is not available or allowed for this account.", 
"Can't find EId with ticker Id:", "Invalid ticker action:", "Error parsing stop ticker string", 
"Invalid action:", "Invalid acct. value action:", "Request parsing error, the request has been ignored.", 
"Error processing DDE request.", "Invalid request topic.", "Unable to create the 'API' page in TWS as the maximum number of pages already exists.", 
"Max number (3) of market depth requests has been reached.", 
"Can't find the subscribed market depth with tickerId:", "The origin is invalid.", 
"The combo details are invalid.", "The combo details for leg '<leg number>' are invalid.", 
"Security type 'BAG' requires combo leg details.", "Stock combo legs are restricted to SMART order routing.", 
"Market depth data has been HALTED. Please re-subscribe.", "Market depth data has been RESET. Please empty deep book contents before applying any new entries.", 
"Advisors cannot modify partially filled orders.", "Attempt to set the server log level failed as the log level was invalid.", 
"Server error when reading an API client request.", "Server error when validating an API client request.", 
"Server error when processing an API client request.", "Server error: cause - %s", 
"Server error when reading a DDE client request - missing data.", 
"Discretionary orders are not supported for this combination of exchange and order type.", 
"Unable connect as the client id is already in use. Retry with a unique client id.", 
"Only API connections with clientId set to 0 can set the auto bind TWS orders property.", 
"Trailing stop orders can be attached to limit or stop-limit orders only.", 
"Order modify failed. Cannot change to the new order type.", 
"Only FA or STL customers can request managed accounts list.", 
"Internal error. FA or STL does not have any managed accounts.", 
"The account codes for the order profile are invalid.", "Invalid share allocation syntax.", 
"Invalid Good Till Date order", "Invalid delta: The delta must be between 0 and 100.", 
"Invalid Expiration Time.", "Invalid Good After Time.", "Good After Time Disabled.", 
"Futures spread no longer supported.", "Invalid improvement amount.", 
"Invalid delta.", "Invalid Peg.", "Invalid Good Till Date.", 
"The account is not a financial advisor account", "Invalid FA inter-market combo order.", 
"Not an institutional account.", "Invalid short slot value.", 
"Not a short sale.", "Invalid GAT inter-market combo.", "Invalid minimum quantity for inter-market combo.", 
"Invalid RTH only designation.", "Bad short slot location.", 
"Short slot location specified.", "Not subscribed to market data.", 
"Order size incorrect.", "Smart-combo OCA not supported.", "Your client version is out of date.", 
"Smart combo child not supported.", "Native combo OCA is incompatible.", 
"What- if check not supported for this Smart inter-market combo.", 
"Invalid trigger price.", "Invalid adjusted stop price.", "Invalid adjusted stop limit price.", 
"Invalid adjusted trailing amount.", "No scanner subscription found for ticker id:", 
"No historical data query found for ticker id:", "Volatility type if set must be 1 or 2 for VOL orders.", 
"Reference Price Type must be 1 or 2 for dynamic volatility management.", 
"Volatility orders are only valid for US options.", "Dynamic Volatility orders must be SMART routed, or trade on a Price Improvement Exchange.", 
"VOL order requires positive floating point value for volatility.", 
"Cannot set dynamic VOL attribute on non-VOL order.", "Can only set stock range attribute on VOL or PEGGED TO STOCK order.", 
"If both are set, the lower stock range attribute must be less than the upper stock range attribute.", 
"Stock range attributes cannot be negative.", "The order is not eligible for continuous update. The option must trade on a cheap-to-reroute exchange.", 
"Must specify valid delta hedge order aux. price.", "Delta hedge order type requires delta hedge aux. price to be specified.", 
"Delta hedge order type requires that no delta hedge aux. price be specified.", 
"This order type is not allowed for delta hedge orders.", "Your DDE.dll needs to be upgraded.", 
"The price specified violates the number of ticks constraint specified in the default order settings.", 
"The size specified violates the size constraint specified in the default order settings.", 
"Invalid DDE array request.", "Duplicate ticker ID for API scanner subscription.", 
"Duplicate ticker ID for API historical data query.", "Unsupported order type for this exchange and security type.", 
"Order size is smaller than the minimum requirement.", "Supplied routed order ID is not unique.", 
"Supplied routed order ID is invalid.", "Invalid date for GTD.", 
"This order is invalid since is uses an expired contract.", "The short slot order has not delta hedge order type.", 
"Invalid process time.", "Direct routed OCA error.", "Direct routed order type error.", 
"Region order type error.", "Direct routed condition error placeholder.", 
"Order message error", "Algo order error.", "Length restriction.", 
"Conditions are not allowed for this contract.", "Invalid stop price.", 
"Allowed quantity message.", "The child order quantity should be equivalent to the parent order size.", 
"The currency (  ) is not allowed.", "The symbol should contain valid non-unicode characters only.", 
"Invalid scale order increment.", "Invalid scale order. You must specify order component size.", 
"Invalid subsequent component size for scale order.", "Invalid outside RTH.", 
"The contract is not available for trading.", "What-if order should have the transmit flag set to true.", 
"Do not use generic ticks for snapshot market data.", "RFQ already sent for the conid.", 
"RFQ not applicable for the contract. Order ID:", "Invalid initial component size for scale order.", 
"Invalid scale order profit offset.", "Missing initial component size for scale order.", 
"Invalid real-time query.", "Invalid route.", "Invalid OMS component attributes.", 
"Already connected.", "Couldn't connect to TWS. Confirm that API is enabled in TWS via the Configure>API menu command.", 
"Your version of TWS is out of date and must be upgraded.", "Not connected.", 
"Fatal error: Unknown message id.", "Request market data - sending error:", 
"Cancel market data - sending error:", "Order - sending error:", 
"Account update request - sending error:", "Request for executions  - sending error:", 
"Cancel order - sending error:", "Request open order - sending error:", 
"Unknown contract. Verify the contract details supplied.", "Request contract data - sending error:", 
"Request market depth - sending error:", "Cancel market depth - sending error:", 
"Set server log level - sending error:", "FA Information Request - sending error:", 
"FA Information Replace - sending error:", "Request Scanner subscription - sending error:", 
"Cancel Scanner subscription - sending error:", "Request Scanner parameter - sending error:", 
"Request Historical data - sending error:", "Cancel Historical data - sending error:", 
"Request real-time bar data - sending error:", "Cancel real-time bar data - sending error:", 
"Connectivity between IB and TWS has been lost.", "Connectivity between IB and TWS has been restored- data lost.", 
"Connectivity between IB and TWS has been restored- data maintained.", 
"TWS socket port has been reset and this connection is being dropped.", 
"New account data requested from TWS.  API client has been unsubscribed from account data.", 
"Unable to subscribe to account as the following clients are subscribed to a different account.", 
"Unable to modify this order as it is still being processed.", 
"A market data farm is disconnected.", "A market data farm is connected.", 
"A historical data farm is disconnected.", "A historical data farm is connected.", 
"A historical data farm connection has become inactive but should be available upon demand.", 
"A market data farm connection has become inactive but should be available upon demand.", 
"Order Event Warning: Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now processed."
), .Dim = c(229L, 1L), .Dimnames = list(c("100", "101", "102", 
"103", "104", "105", "106", "107", "109", "110", "111", "113", 
"114", "115", "116", "117", "118", "119", "120", "121", "122", 
"123", "124", "125", "126", "127", "128", "129", "131", "132", 
"133", "134", "135", "136", "137", "138", "139", "140", "141", 
"142", "143", "144", "145", "146", "147", "148", "151", "152", 
"153", "154", "155", "156", "157", "158", "159", "160", "161", 
"162", "165", "166", "167", "168", "200", "201", "202", "203", 
"300", "301", "302", "303", "304", "305", "306", "307", "308", 
"309", "310", "311", "312", "313", "314", "315", "316", "317", 
"318", "319", "320", "321", "322", "323", "324", "325", "326", 
"327", "328", "329", "330", "331", "332", "333", "334", "335", 
"336", "337", "338", "339", "340", "341", "342", "343", "344", 
"345", "346", "347", "348", "349", "350", "351", "352", "353", 
"354", "355", "356", "357", "358", "359", "360", "361", "362", 
"363", "364", "365", "366", "367", "368", "369", "370", "371", 
"372", "373", "374", "375", "376", "377", "378", "379", "380", 
"381", "382", "383", "384", "385", "386", "387", "388", "389", 
"390", "391", "392", "393", "394", "395", "396", "397", "398", 
"399", "400", "401", "402", "403", "404", "405", "406", "407", 
"408", "409", "410", "411", "412", "413", "414", "415", "416", 
"417", "418", "419", "420", "421", "422", "501", "502", "503", 
"504", "505", "510", "511", "512", "513", "514", "515", "516", 
"517", "518", "519", "520", "521", "522", "523", "524", "525", 
"526", "527", "528", "529", "530", "531", "1101", "1102", "1300", 
"2100", "2101", "2102", "2103", "2104", "2105", "2106", "2107", 
"2108", "2109"), NULL))
